package com.dao;

import com.Util.MybatisUtils;
import com.po.Book;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class BookDao {
    public List<Book> findBook(Book book) throws Exception{
        SqlSession sqlSession = MybatisUtils.getSession();
        List<Book> books = sqlSession.selectList("com.mapper"
                + ".BookMapper.findBook", book);

        // 5、关闭SqlSession
        sqlSession.close();
        return books;

    }

    /*
	根据ID查询shu
	*/
    public Book findBookById(Integer id) throws Exception {
        SqlSession sqlSession = MybatisUtils.getSession();
        Book book = sqlSession.selectOne("com.mapper"
                + ".BookMapper.findBookById", id);
        System.out.println(book);
        sqlSession.close();
        return book;


    }
}
